package servlets;

import bean.Book;
import bean.Cart;
import dao.Bookdao;
import dao.Cartdao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/addbook")
public class addbook extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Bookdao bookdao = new Bookdao();
        Book book = new Book();
        book.setHead_title(request.getParameter("head_title"));
        System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        System.out.println(request.getParameter("price"));
        book.setPrice(Double.valueOf( request.getParameter("price")));
        book.setName(request.getParameter("name"));
        book.setLinktoimg(request.getParameter("linktoimg"));
        book.setIsbn(request.getParameter("isbn"));
        book.setAuthor(request.getParameter("author"));
        book.setNum(Integer.valueOf(request.getParameter("num") ));
        book.setKind(request.getParameter("kind"));
        bookdao.addBook(book);
        response.sendRedirect("management.jsp");
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
